{% extends base.html %}

{% block head %}
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script> !window.jQuery && document.write('<script type="text/javascript" src=\"{{static_url("js/jquery-1.4.3.min.js")}}\"><\/script>'); </script>
<script type="text/javascript" src="{{static_url('js/fancybox/jquery.fancybox-1.3.4.pack.js')}}"></script>
<link rel="stylesheet" href="{{static_url('js/fancybox/jquery.fancybox-1.3.4.css')}}" type="text/css" media="screen" />
<style>
body { min-width: 990px; }
</style>
{% block more_head %}{% end %}
{% end %}

{% block body %}
  {% block body-top %}{% end %}
  <div id="layout-top">
    <div id="top-left">
      <a href="/" title="{{ options.site_name }}">{{ options.site_name }}</a>
    </div>
    <div id="search">
      <form action="/">
        <div style="width: 276px; height: 28px; background-image: url('{{ static_url('img/qbar.png') }}'); background-repeat: no-repeat; display: inline-block;">
          <input type="text" maxlength="40" name="q" id="search-q" value="">
        </div>
      </form>
    </div>
    
    <div id="top-right">
    <ul class="menu">
      {% if current_user %}
      <li><a href="/uploader/{{ current_user['id'] }}">{{ current_user['name'] }}</a></li>
      <li><a href="/login?logout=1">登出</a></li>
      <li><a class="openmulti get-lixian-url iframe" href="/get_lixian_url?task_id=">打开所选</a></li>
      <li><a class="sharemulti" href="/share" target="_blank">分享所选</a></li>
      <li>
          <form action="javascript:selectKeywordTask();">
              <input type="text" maxlength="40" name="q" id="quick-key" value="关键字选择">
          </form>
      </li>
      {% if handler.has_permission("admin") %}<li><a href="/manager">系统管理</a></li>{% end %}
      <li><a href="/add_task" class="iframe add-task">发布资源</a></li>
      <li class="last"><a href="/add_task_anonymous" class="iframe add-task-anonymous">获取离线地址</a></li>
      {% else %}
      <li class="last"><a href="/login" class="iframe add-task">登录</a></li>
      {% end %}
    </ul>
    </div>
  </div>
  <div id="layout-list">{% block list %}{% end %}</div>
  <!--<div id="layout-background">
    <div class="logo">
      <div class="text">
        <span>{{ options.site_name }}</span>
      </div>
    </div>
  </div>-->
  <div id="layout-info">
    <div class="info-box">{% block info %}{% end %}</div>
  </div>
  <div class="clearfix"></div>
<script>
  $(".add-task").fancybox({width: 700, height: 250});
  $(".add-task-anonymous").fancybox({width: 700, height: 90});
  function check_cross_cookie() {
    document.cookie.match(/cross-cookie\s*=\s*{{ options.cross_cookie_version }}/i) ? true : false;
  }
  
  $(".sharemulti").mouseover(function(event){
      //event.stopPropagation();
      var exports=[];
      $("input.select_task").each(function(i,n){if (n.checked) exports.push(n.id.replace("tid-",""))});
      if (exports.length != 0){
        $(this).attr("href", "/share/"+exports.join(","));
      }
      else
      {
        $(this).attr("href", "/");
      }
  });
  $(".openmulti").mouseover(function(event){
      //event.stopPropagation();
      var exports=[];
      $("input.select_task").each(function(i,n){if (n.checked) exports.push(n.id.replace("tid-",""))});
      if (exports.length != 0) {
        $(this).attr("href", "/get_lixian_url?task_id="+exports.join(","));
      }
      else{
        $(this).attr("href", "/");
      }
  });
  
  function selectKeywordTask() {
    $("input.select_task").attr('checked', false);
    keyword = $("#quick-key").val()
    if (keyword == "") return;
    $("input."+"quick_select_data[value*="+keyword+"]").each(
        function(i,n){
            tid = n.id;
            $("input.select_task#tid-"+tid).attr('checked', true);
        });
  }
  $("#quick-key").focus(function () {
         $(this).attr("value","");
    });
</script>
{% end %}
